package timing.ukulele.third.controller.msg;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import timing.ukulele.common.data.ResponseData;
import timing.ukulele.data.third.data.msg.ChannelAccountGroupDTO;
import timing.ukulele.data.third.view.msg.ChannelAccountGroupVO;
import timing.ukulele.third.service.msg.ChannelAccountGroupService;

/**
 * 渠道账号组管理接口
 *
 * @author zh
 */
@RestController
@RequestMapping("/msg/channelAccountGroup")
@Slf4j
public class ChannelAccountGroupController {

    private final ChannelAccountGroupService service;

    public ChannelAccountGroupController(ChannelAccountGroupService service) {
        this.service = service;
    }

    /**
     * /msg/channelAccountGroup/addChannelAccountGroup
     * @param dto
     * @return
     */
    @PostMapping("/addChannelAccountGroup")
    @Operation(summary = "新增渠道账号组")
    public ResponseData<Boolean> addChannelAccountGroup(@RequestBody ChannelAccountGroupDTO dto) {
        return ResponseData.success(service.addChannelAccountGroup(dto));
    }

    /**
     * /msg/channelAccountGroup/updateChannelAccountGroup
     * @param dto
     * @return
     */
    @PutMapping("/updateChannelAccountGroup")
    @Operation(summary = "新增渠道账号组")
    public ResponseData<Boolean> updateChannelAccountGroup(@RequestBody ChannelAccountGroupDTO dto) {
        return ResponseData.success(service.updateChannelAccountGroup(dto));
    }

    /**
     * /msg/channelAccount/deleteChannelAccountGroup
     * @param id
     * @return
     */
    @DeleteMapping("/deleteChannelAccountGroup")
    @Operation(summary = "删除渠道账号组")
    public ResponseData<Boolean> deleteChannelAccountGroup(@RequestParam("id") Long id) {
        return ResponseData.success(service.deleteChannelAccountGroup(id));
    }

    /**
     * /msg/channelAccount/page
     * @param dto
     * @return
     */
    @GetMapping("/page")
    @Operation(summary = "渠道账号组分页列表")
    public ResponseData<IPage<ChannelAccountGroupVO>> page(ChannelAccountGroupDTO dto) {
        return ResponseData.success(service.pageList(dto));
    }

}
